#!/usr/bin/env python3

import json
import os
import subprocess
import sys
from os import path
import tempfile
from subprocess import Popen, PIPE, DEVNULL
import plx

if len(sys.argv) < 2:
    print("Usage: buildlist <list_file>")
    sys.exit(1)

list_file = sys.argv[1]

f = open(list_file)
pcks = f.readlines()

for pck in pcks:
    print("Building package: ", pck)

    if not plx.build_package(pck):
        print("FAILED: " + pck)
        sys.exit(1)

print("")
print("Finished installing list: " + list_file)
